import time
def run_time(func):
    def diff_time():
        start = time.time()
        func()
        end = time.time()
        print('%s执行了%f秒' % (func.__name__,end-start))
    return diff_time

@run_time
def run():
    time.sleep(2)
    l = [x**2 for x in range(20)]

run()